#include<iostream>
#include<unistd.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<pthread.h>
#include<ifaddrs.h>
#include<sys/epoll.h>
#include<ctype.h>
#include<stdlib.h>
#include<netinet/in.h>
#include<cstring>
#include"sqlQuery.h"
#include<map>
#include<memory>
#include<cstring>

#define MaxConnet 512
#define HeaderSize 7
#define RWMaxSize 1024
#define MaxPackSize 800
#define RemarkSize  20
#define ContentSize 24
#define MaxContentSum (800/24)


#define ServerPort 5500
#define ServerLocalHost "127.0.0.1"

#define Fooddb	"../data/food.db"
#define Tabledb "table.db"
#define Saledb	"sale.db"
#define Orderdb "desk.db"
//home的status为0空闲，1正在服务，2呼叫服务员，3要结帐,4可以上菜（厨房动作）,5正在换房
#define SqlInitHome    "create table home(id int,name text,status int)"
#define SqlinitMenu    "create table menu(id int,name text,price int,status int)"
#define SqlinitOrder   "create table desk(id int,name text,sum int,tablenum int,status int)"

#define OrderClient       '1' //客户
#define ReceptionClient	  '2' //前台
#define CookClient        '3' //厨房


#define IsEnd             '1' //结束
#define NoEnd		  '2' //未结束

#define ConnetOrderTable  '1' //订房间
#define ConnetOrderFood   '2' //订菜
#define ConnetDeleteFood  '3' //删菜
#define ConnetAddFood     '4' //update加菜
#define ConnetCallWaiter  '5' //呼叫服务员
#define ConnetAccount     '6' //结帐
#define ConnetGetTable    '7' //获取开台信息
#define ConnetGetFood     '8' //获取菜单列表
#define ConnetChangeTable '9' //换房间

#define ConnetAllTable         'a' //获取全部房间
#define ConnetGetCallWaiter    'b'//获取呼叫服务员房间
#define ConnetGetAccount       'c' //获取要结帐的房间
#define ConnetFinishFood       'd'//上菜完毕
#define ConnetGetUsedTable     'e'//获取正在消费的房间
#define ConnetDeelChangeTable  'f'//处理换房
#define ConnetGetChangeTable   'g'//处理换房
#define ConnetGetOrderFood     'h'//获取用户菜单

#define ConnetAddNewFood       'i' //insert点菜加新菜

#define ConnetOkFood          'x' //上菜
#define ConnetNewFood         'y' //新菜上线
#define ConnetOldFood         'z' //老菜下线
#define ConnetGetDownFood     'v' //获取已下线的菜单
#define ConnetUpOldFood       'o' //上线已下线的菜单

#define SizeofTypeInContent    2//struct Content里的FoodNum字节长度 



typedef unsigned short ushort;
typedef unsigned int   uint;

using namespace std;

struct Content{
    ushort FoodNum;//编号
    ushort FoodSum;//数量
    char Remark[RemarkSize];//备注
};


struct MessageHeader{
    char client;
    char PackIsEnd;
    char ConnetType;
    ushort TableNum;
    ushort ContentSum;

};
/*
struct ContentList{
    ushort FoodNum;//编号
    ushort FoodSum;//数量
    char Remark[RemarkSize];//备注
    //map<ushort,map<ushort,string>> list;//菜编号-数量-备注
    struct ContentList *next;
    struct ContentList *pre;
};
*/



